#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
const int N = 1e3 + 10;

void solve()
{

	int a[N] = { 0 };
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int num;
		cin >> num;
		a[num]++;
	}
	for (int i = 1; i <= n; i++)
	{
		a[i] = a[i] + a[i - 1];
	}
	int f = 0;
	for (int i = 0; i <= n; i++)
	{
		if (a[i]==n-i)
		{
			f = 1;
			cout << i << endl;
			break;
		}
	}
	if (!f) cout << -1 << endl;
}
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		solve();
	}


	return 0;
}

